package cc.chenwenxi.entity;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import cn.hutool.core.date.DateUtil;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
@Document(collection = "love_chat")
public class Chat implements Serializable {
	private static final long serialVersionUID = -2705268510249827540L;
	@Id
	private String id;
	private String userid;
	private String nickname;
	private String face;
	private String words;
	private String time;
	@Indexed
	private Date createTime;

	public Chat(String userid, String nickname, String face, String words) {
		super();
		this.userid = userid;
		this.nickname = nickname;
		this.face = face;
		this.words = words;
		Date date = new Date();
		this.createTime = date;
		this.time = DateUtil.format(date, new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"));
	}
}